package chapter06

object Test04_Access {
  def main(args: Array[String]): Unit = {
    val person:Person = new Person()
//    person.idCard error private 同类和伴生对象才可以访问
// protected 只有同类，和子类才可以访问，很明显，这里访问不老
//    println(person.name) error

    println(person.age)// private [包名]
    println(person.sex)// default public
  }
}

// 定义一个子类
class Worker extends Person{
  //  idCard not found
  override def printInfo(): Unit = {
    println("Worker: ")
    name = "pipi"
    age = 25
    sex = "male"
  }
}
